var BASEURL = 'https://kq.lsyat.com/';
//var BASEURL = 'https://www.faceid.space/';
// var BASEURL = 'http://test.kq.lsyat.com/'
//var BASEURL = 'http://192.168.0.190:8089/'

// var BASEURL = 'http://kq.lsyat.com/';
// var BASEURL = 'https://kq.focus-face.com/';
/**
 * PROJECT_VERSION 项目版本,可能会有临时需求,用来判断
 * yinni 印尼版本
 * yundianmao 主版本
 */

var PROJECT_VERSION = 'Indonesia'

//对应版本标识
var PROJECT_MASTER = 'yundianmao'
var PROJECT_YINNI = 'Indonesia'

/**
 * img使用的版本
 */
var IMG_VERSION = "oss";

var OSS = "oss"
var LOCAL = "local"


//鉴权链接
var AUTHORIZE = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx48ed814549dfe8a7&redirect_uri=https://kq.lsyat.com/yundianmao/emp/index.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
// 鉴面
// var AUTHORIZE = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxee30b5c1bc03ca3c&redirect_uri=https://kq.focus-face.com/yundianmao/emp/index.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";

//request url
var GET_PHONE_CODE = 'attrecordController.do?Verificationscode'; //获取短信验证码
var GET_OPENID = 'attrecordController.do?Wxregistergo' //获取微信openId
var CHECK_USER_BIND = 'attrecordController.do?isbindingemp' //检测用户是否绑定
var GET_CONFIG = 'attrecordController.do?getConfig' //获取微信jssdk验证信息
var BIND_EMPLOYEE = 'attrecordController.do?bindingemp' //绑定员工和公众号
var SELECT_COMPANY = 'attrecordController.do?setdefault'  //选择公司 
var GET_DEPART_TREE = 'attrecordController.do?getpersonnel' //获取部门树
var GET_LEAVE_TYPE = 'attrecordController.do?leavetype' //获取请假类型
var COUNT_LEAVE_TIME = 'attrecordController.do?leavevt' //计算请假时间
var SUBMIT_LEAVE = 'attrecordController.do?leavesave' //提交请假单
var GET_LEAVE_LIST = 'attrecordController.do?leavesinfo' //获取请假列表
var VIEW_LEAVE_DETAILS = 'attrecordController.do?leavedetail' //查看请假明细
var GET_APPROVAL_PENDING = 'attrecordController.do?stayhandle' //获取待审批
var SUBMIT_APPROVAL = 'attrecordController.do?Approval' //审批
var APPROVED = 'attrecordController.do?alreadyhandle' //已审批
var GET_ATTENDANCE_RECORD = 'attrecordController.do?attrecordemppage' //获取考勤记录
var GET_MESSAGE_TOTAL = 'attrecordController.do?messageinfo'  // 获取消息数量
var GET_MYSELF_INFO = 'attrecordController.do?emplist' //获取个人信息
var SUBMIT_BUSINESS_TRAVEL = 'attrecordController.do?gooutsave' //提交出差单
var COUNT_BUSINESS_TRAVEL_TIME='attrecordController.do?gooutvt' //计算出差时间
var ADD_PARCH_APPLY = 'attrecordController.do?patchsave'//补卡申请
var PSD_LOGIN = 'attrecordController.do?isbindingemp'//密码登陆
var REGISTER_USER= 'attrecordController.do?bindingemp' //用户注册
// var CHECK_PERSON_IN_IMG = 'attrecordController.do?checkface2' //检测人脸
var CHECK_PERSON_IN_IMG = 'attrecordController.do?checkfacelo' //检测人脸 （印尼）
var ADD_VISITOR = 'attrecordController.do?visitorsave' //添加访客
var UNBIND_USER = 'attrecordController.do?Untyingemp' //解除绑定
var ADD_EMPLOYEE = 'attrecordController.do?addface' //注册员工(人脸)
var GET_CERTIFICATE_TYPE = 'faceWhitelistController.do?listalls' //获取证件类型

module.exports = {
	BASEURL,
	AUTHORIZE,
	GET_PHONE_CODE,
	GET_OPENID,
	CHECK_USER_BIND,
	GET_CONFIG,
	BIND_EMPLOYEE,
	SELECT_COMPANY,
	GET_DEPART_TREE,
	GET_LEAVE_TYPE,
	COUNT_LEAVE_TIME,
	SUBMIT_LEAVE,
	GET_LEAVE_LIST,
	VIEW_LEAVE_DETAILS,
	GET_APPROVAL_PENDING,
	SUBMIT_APPROVAL,
	APPROVED,
	GET_ATTENDANCE_RECORD,
	GET_MESSAGE_TOTAL,
	GET_MYSELF_INFO,
	SUBMIT_BUSINESS_TRAVEL,
	COUNT_BUSINESS_TRAVEL_TIME,
	ADD_PARCH_APPLY,
	PROJECT_MASTER,
	PROJECT_YINNI,
	PSD_LOGIN,
	REGISTER_USER,
	CHECK_PERSON_IN_IMG,
	ADD_VISITOR,
	UNBIND_USER,
	IMG_VERSION,
	PROJECT_VERSION,
	OSS,
	LOCAL,
	ADD_EMPLOYEE,
	getUserid,
	getUnitno,
	saveUserid,
	saveUnitno,
	checkUserInfo,
	GET_CERTIFICATE_TYPE
}

function getUserid(){
	const value = uni.getStorageSync('userid');
	console.log(value)
	return value
}

function getUnitno(){
	const value = uni.getStorageSync('unitno');
	return value
}

function saveUserid(userid){
	uni.setStorage({
	    key: 'userid',
	    data: userid,
	    success: function () {
	        console.log('userid save success');
	    }
	});
}

function saveUnitno(unitno){
	uni.setStorage({
	    key: 'unitno',
	    data: unitno,
	    success: function () {
	        console.log('unitno save success');
	    }
	});
}

/**
 * 检查该页面的globalData里面的userid，和unitno是否为null
 * 若过为null,说明页面被刷新过，就从缓存里面取
 * 否则不管
 */
function checkUserInfo(){
	let userid = getApp().globalData.userid
	let unitno = getApp().globalData.unitno
	if(userid == ''){
		let id = getUserid()
		getApp().globalData.userid = id
	}
	if(unitno == ''){
		let unitno = getUnitno()
		getApp().globalData.unitno = unitno
	}
	// console.log(getApp().globalData.userid)
	// console.log(getApp().globalData.unitno)
}